<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时 间歇函数</title>
</head>



<body>
    <button class="but"> 剩余60秒</button>
    <script>
        //setInterval(函数，时间（毫秒）)
        // setInterval(function(){
        //     document.write('999')
        // },1000)



        // function fn() {
        //     document.write('wc 盒')
        // }
        // setInterval(fn, 5000)
        // let time = setInterval(function () {
        //     document.write('盒')
        // }, 500)
        // let time1 = setInterval(function () {
        //     document.write('wc')
        // }, 500)
        //会按顺序
        const button1 = document.querySelector('.but')

        let i = 60
        let time = setInterval(function () {
            i--;
            button1.textContent = `剩余${i}秒`
            if (i <= 0) {
                clearInterval(time);
                button1.textContent = '允许起飞';
                button1.disabled = false;
            }
        }, 1000)
        button1.disabled = true;


    </script>
</body>

</html>